import 'package:demo/config/app_resource.dart';
import 'package:demo/event/event_setting.dart';
import 'package:demo/tools/tools_enum.dart';
import 'package:demo/tools/tools_sqlite.dart';
import 'package:demo/tools/tools_storage.dart';

// 好友接口
class JsonFriend {
  // 好友列表
  static Future<List<ChatFriend>> getFriendList() async {
    List<String> portraitList = [
      AppImage.i0,
      AppImage.i1,
      AppImage.i2,
      AppImage.i3,
      AppImage.i4,
    ];
    List<ChatFriend> dataList = [];
    for (var i = 1; i < 6; i++) {
      dataList.add(ChatFriend(
        '123456789123456780$i',
        portraitList[i - 1],
        '好友$i',
        '8888888$i',
        '',
        '',
        'N',
        'N',
        'N',
      ));
    }
    LocalUser localUser = ToolsStorage().local();
    // 自己
    dataList.add(ChatFriend(
      localUser.userId,
      localUser.portrait,
      localUser.nickname,
      localUser.userNo,
      '',
      localUser.intro,
      'N',
      'N',
      'N',
    ));
    // 存储
    await ToolsSqlite().friend.addBatch(dataList);
    // 通知
    EventSetting().event.add(SettingModel(SettingType.friend));
    return dataList;
  }
}
